package utils;

import java.io.FileInputStream;
import java.io.IOException;
import java.sql.*;
import java.util.Properties;

public class utils {
    private static String user;
    private static String password;
    private static String url;
    private static String driver;

    static {
        try {
            Properties properties=new Properties();
            properties.load(new FileInputStream("src\\mysql.properities"));
            user=properties.getProperty("user");
            password=properties.getProperty("password");
            url=properties.getProperty("url");
            driver=properties.getProperty("driver");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
public static Connection getconnection(){
    try {
        return DriverManager.getConnection(url,user,password);
    } catch (SQLException e) {
        throw new RuntimeException(e);
    }
}
public static void close(ResultSet resultSet, Statement statement,Connection connection){
            try {
                if (resultSet!=null){
                resultSet.close();
                }
                if (statement!=null){
                    statement.close();
                }
                if (connection!=null){
                    connection.close();
                }
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
        }
}

